<?php
$directory = "data/";

if (isset($_POST['usertitle'])&&!empty($_POST['usertitle'])&&
    isset($_POST['userevent'])&&!empty($_POST['userevent']))
{
  $usertitle = $_POST['usertitle'];
  $userevent = $_POST['userevent'];
  $fp = fopen($directory.'userevent.dat', 'a');
  fwrite($fp, $usertitle.",".$userevent."\r\n");
  fclose($fp);
  echo $userevent;
}
else
{
  echo "error";
}
?>